package com.wsx.ones.monitor.core.netty;

import com.wsx.ones.monitor.core.serialize.RpcSerializeProtocol;
import com.wsx.ones.monitor.core.serialize.hession.HessionMessageCodec;
import com.wsx.ones.monitor.core.serialize.hession.HessionMessageDecoder;
import com.wsx.ones.monitor.core.serialize.hession.HessionMessageEncoder;
import io.netty.channel.ChannelPipeline;

/**
 * 通道流的具体实现类，根据序列化的不同设置不同的编码解码
 * 主要区别是序列化不同，编码解码也是不尽相同
 *
 * Created by wangshuaixin on 17/2/6.
 */
public class PushPipelineFrame {

    /**
     * 设置相应的编码解码操作
     *
     * @param pipeline
     * @param protocol
     */
    public static void initPipeline(ChannelPipeline pipeline, RpcSerializeProtocol protocol) {
        switch (protocol) {
            case HESSIONSERIALIZE:
                HessionMessageCodec codec = new HessionMessageCodec();
                pipeline.addLast(new HessionMessageDecoder(codec));
                pipeline.addLast(new HessionMessageEncoder(codec));
                pipeline.addLast(new PushMessageHandler());
                break;
            case KRYOSERIALIZE:
                break;
        }
    }
}
